home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / dev / obero / oberon_lib.lha / oberon-a / source1.lha / source / Amiga / Commodities.mod < prev    next >
Text File  |  1994-08-08  |  13KB  |  472 lines

  1. (***************************************************************************
  2.  
  3.      $RCSfile: Commodities.mod $
  4.   Description: Interface to commodities.library
  5.  
  6.    Created by: fjc (Frank Copeland)
  7.     $Revision: 3.2 $
  8.       $Author: fjc $
  9.         $Date: 1994/08/08 00:57:41 $
  10.  
  11.   Includes Release 40.15
  12.  
  13.   (C) Copyright 1985-1993 Commodore-Amiga, Inc.
  14.       All Rights Reserved
  15.  
  16.   Oberon-A interface Copyright © 1994, Frank Copeland.
  17.   This file is part of the Oberon-A Interface.
  18.   See Oberon-A.doc for conditions of use and distribution.
  19.  
  20. ***************************************************************************)
  21.  
  22. MODULE Commodities;
  23.  
  24. (*
  25. ** $C- CaseChk       $I- IndexChk  $L+ LongAdr   $N- NilChk
  26. ** $P- PortableCode  $R- RangeChk  $S- StackChk  $T- TypeChk
  27. ** $V- OvflChk       $Z- ZeroVars
  28. *)
  29.  
  30. IMPORT E := Exec, IE := InputEvent, KM := KeyMap, SYS := SYSTEM;
  31.  
  32. (**-- Pointer declarations ---------------------------------------------*)
  33.  
  34. TYPE
  35.  
  36.   NewBrokerPtr *      = CPOINTER TO NewBroker;
  37.   InputXpressionPtr * = CPOINTER TO InputXpression;
  38.   IXPtr *             = CPOINTER TO IX;
  39.   CxObjPtr *          = CPOINTER TO CxObj;
  40.   CxMsgPtr *          = CPOINTER TO CxMsg;
  41.  
  42. (*
  43. **      $VER: commodities.h 38.4 (24.2.93)
  44. **
  45. **      Commodities definitions.
  46. *)
  47.  
  48. (*****************************************************************************)
  49.  
  50. TYPE
  51.  
  52.   NewBroker * = RECORD
  53.     version * :  SHORTINT;        (* Must be set to NB_VERSION *)
  54.     name *    :  E.STRPTR;
  55.     title *   :  E.STRPTR;
  56.     descr *   :  E.STRPTR;
  57.     unique *  :  E.WSET;
  58.     flags *   :  E.WSET;
  59.     pri *     :  SHORTINT;
  60.     port *    :  E.MsgPortPtr;
  61.     reservedChannel * :  INTEGER;
  62.   END;
  63.  
  64. CONST
  65.  
  66. (* constant for NewBroker.version *)
  67.   nbVersion * = 5;          (* Version of NewBroker structure *)
  68.  
  69. (* Sizes for various buffers *)
  70.   cbdNamelen * = 24;
  71.   cbdTitlelen * = 40;
  72.   cbdDescrlen * = 40;
  73.  
  74. (* Flags for NewBroker.unique *)
  75.   nbuDuplicate * = 0;
  76.   nbuUnique * = 1;             (* will not allow duplicates           *)
  77.   nbuNotify * = 2;             (* sends cxmUnique to existing broker *)
  78.  
  79. (* Flags for NewBroker.flags *)
  80.   cofShowHide * = 4;
  81.  
  82.  
  83. (*****************************************************************************)
  84.  
  85. TYPE
  86.  
  87. (* Fake data types for system private objects *)
  88.   CxObj = RECORD END;
  89.   CxMsg = RECORD END;
  90.  
  91. (* Pointer to a function returning a LONG *)
  92.   PFL = PROCEDURE () : LONGINT;
  93.  
  94.  
  95. (*****************************************************************************)
  96.  
  97. CONST
  98.  
  99. (* Commodities object types *)
  100.   invalid *    = 0;  (* not a valid object (probably null) *)
  101.   filter *     = 1;  (* input event messages only          *)
  102.   typeFilter * = 2;  (* obsolete, do not use               *)
  103.   send *       = 3;  (* sends a message                    *)
  104.   signal *     = 4;  (* sends a signal                     *)
  105.   translate *  = 5;  (* translates input event into chain  *)
  106.   broker *     = 6;  (* application representative         *)
  107.   debug *      = 7;  (* dumps info to serial port          *)
  108.   custom *     = 8;  (* application provides function      *)
  109.   zero *       = 9;  (* system terminator node             *)
  110.  
  111.  
  112. (*****************************************************************************)
  113.  
  114. CONST
  115.  
  116. (* Commodities message types *)
  117.   mIEvent * = 32;
  118.   mCommand * = 64;
  119.  
  120. (* Only mIEvent messages are passed through the input network. Other types
  121.  * of messages are sent to an optional port in your broker. This means that
  122.  * you must test the message type in your message handling, if input messages
  123.  * and command messages come to the same port.
  124.  *
  125.  * mIEvent:    Messages of this type rattle around the Commodities input
  126.  *             network. They are sent to you by a Sender object, and passed
  127.  *             to you as a synchronous function call by a Custom object.
  128.  *
  129.  *             The message port or function entry point is stored in the
  130.  *             object, and the ID field of the message will be set to what
  131.  *             you arrange issuing object.
  132.  *
  133.  *             The data section of the message will point to the input event
  134.  *             triggering the message.
  135.  *
  136.  * mCommand:   These messages are sent to a port attached to your Broker.
  137.  *             They are sent to you when the controller program wants your
  138.  *             program to do something. The ID value identifies the command.
  139.  *)
  140.  
  141. CONST
  142.  
  143. (* ID values associated with a message of type mCommand *)
  144.   cmdDisable * = 15;        (* please disable yourself         *)
  145.   cmdEnable * = 17;         (* please enable yourself  *)
  146.   cmdAppear * = 19;         (* open your window, if you can    *)
  147.   cmdDisappear * = 21;      (* go dormant                      *)
  148.   cmdKill * = 23;           (* go away for good                *)
  149.   cmdListChg * = 27;        (* Someone changed the broker list *)
  150.   cmdUnique * = 25;         (* someone tried to create a broker
  151.                              * with your name. Suggest you appear.
  152.                              *)
  153.  
  154.  
  155. (*****************************************************************************)
  156.  
  157. TYPE
  158.  
  159.   InputXpression * = RECORD
  160.     version *   :  E.UBYTE;  (* must be set to ixVersion *)
  161.     class *     :  E.UBYTE;  (* class must match exactly  *)
  162.  
  163.     code *      :  E.WSET;   (* Bits that we want *)
  164.     codeMask *  :  E.WSET;   (* Set bits here to indicate which bits in code
  165.                               * are don't care bits.
  166.                               *)
  167.     qualifier * :  E.WSET;   (* Bits that we want *)
  168.     qualMask *  :  E.WSET;   (* Set bits here to indicate which bits in
  169.                               * qualifier are don't care bits
  170.                               *)
  171.     qualSame *  :  E.WSET;   (* synonyms in qualifier *)
  172.   END;
  173.  
  174.   IX * = InputXpression;
  175.  
  176. CONST
  177.  
  178. (* constant for InputXpression.version *)
  179.   ixVersion * = 2;
  180.  
  181. (* constants for InputXpression.qualSame *)
  182.   ixsymShift * = 0;     (* left- and right- shift are equivalent     *)
  183.   ixsymCaps * = 1;      (* either shift or caps lock are equivalent  *)
  184.   ixsymAlt * = 2;       (* left- and right- alt are equivalent       *)
  185.  
  186.   ixsymShiftMask * = {IE.qualLShift, IE.qualRShift};
  187.   ixsymCapsMask * = ixsymShiftMask + {IE.qualCapsLock};
  188.   ixsymAltMask * = {IE.qualLAlt, IE.qualRAlt};
  189.  
  190. (* constant for InputXpression.qualMask *)
  191.   ixNormalQuals * = {0..14};       (* avoid RELATIVEMOUSE *)
  192.  
  193.  
  194. (*****************************************************************************)
  195.  
  196. CONST
  197.  
  198. (* Error returns from CxBroker() *)
  199.   cbErrOk * = 0;          (* No error                               *)
  200.   cbErrSysErr * = 1;      (* System error, no memory, etc           *)
  201.   cbErrDup * = 2;         (* uniqueness violation                   *)
  202.   cbErrVersion * = 3;     (* didn't understand NewBroker.nb_Version *)
  203.  
  204.  
  205. (*****************************************************************************)
  206.  
  207. CONST
  208.  
  209. (* Return values from CxObjError() *)
  210.   coErrIsNull * = 1;           (* you called CxObjError(NULL)        *)
  211.   coErrNullAttach * = 2;       (* someone attached NULL to my list   *)
  212.   coErrBadFilter * = 4;        (* a bad filter description was given *)
  213.   coErrBadType * = 8;          (* unmatched type-specific operation  *)
  214.  
  215.  
  216. (*****************************************************************************)
  217.  
  218.  
  219. (**-- Library Base variable --------------------------------------------*)
  220.  
  221. TYPE
  222.  
  223.   CommoditiesBasePtr * = CPOINTER TO CommoditiesBase;
  224.   CommoditiesBase * = RECORD (E.Library) END;
  225.  
  226. CONST
  227.  
  228.   name * = "commodities.library";
  229.  
  230. VAR
  231.  
  232.   base * : CommoditiesBasePtr;
  233.  
  234.  
  235. (**-- Library Functions ------------------------------------------------*)
  236.  
  237. (*
  238. **      $VER: commodities_protos.h 38.4 (27.2.92)
  239. *)
  240.  
  241. TYPE
  242.   CustomProcType * = PROCEDURE ( obj : CxObjPtr; msg : CxMsgPtr );
  243.  
  244. (* --- functions in V36 or higher (distributed as Release 2.0) ---*)
  245.  
  246. (*  OBJECT UTILITIES *)
  247.  
  248. LIBCALL (base : CommoditiesBasePtr) CreateCxObj*
  249.   ( type [0] : E.ULONG;
  250.     arg1 [8] : SYS.LONGWORD;
  251.     arg2 [9] : SYS.LONGWORD )
  252.   : CxObjPtr;
  253.   -30;
  254. LIBCALL (base : CommoditiesBasePtr) CxBroker*
  255.   ( VAR nb    [8] : NewBroker;
  256.     VAR error [0] : LONGINT )
  257.   : CxObjPtr;
  258.   -36;
  259. LIBCALL (base : CommoditiesBasePtr) ActivateCxObj*
  260.   ( co   [8] : CxObjPtr;
  261.     true [0] : E.LBOOL )
  262.   : E.LBOOL;
  263.   -42;
  264. LIBCALL (base : CommoditiesBasePtr) DeleteCxObj*
  265.   ( co [8] : CxObjPtr );
  266.   -48;
  267. LIBCALL (base : CommoditiesBasePtr) DeleteCxObjAll*
  268.   ( co [8] : CxObjPtr );
  269.   -54;
  270. LIBCALL (base : CommoditiesBasePtr) CxObjType*
  271.   ( co [8] : CxObjPtr )
  272.   : E.ULONG;
  273.   -60;
  274. LIBCALL (base : CommoditiesBasePtr) CxObjError*
  275.   ( co [8] : CxObjPtr )
  276.   : SET;
  277.   -66;
  278. LIBCALL (base : CommoditiesBasePtr) ClearCxObjError*
  279.   ( co [8] : CxObjPtr );
  280.   -72;
  281. LIBCALL (base : CommoditiesBasePtr) SetCxObjPri*
  282.   ( co  [8] : CxObjPtr;
  283.     pri [0] : LONGINT )
  284.   : LONGINT;
  285.   -78;
  286.  
  287. (*  OBJECT ATTACHMENT *)
  288.  
  289. LIBCALL (base : CommoditiesBasePtr) AttachCxObj*
  290.   ( headObj [8] : CxObjPtr;
  291.     co      [9] : CxObjPtr );
  292.   -84;
  293. LIBCALL (base : CommoditiesBasePtr) EnqueueCxObj*
  294.   ( headObj [8] : CxObjPtr;
  295.     co      [9] : CxObjPtr );
  296.   -90;
  297. LIBCALL (base : CommoditiesBasePtr) InsertCxObj*
  298.   ( headObj [8] : CxObjPtr;
  299.     co      [9] : CxObjPtr;
  300.     pred   [10] : CxObjPtr );
  301.   -96;
  302. LIBCALL (base : CommoditiesBasePtr) RemoveCxObj*
  303.   ( co [8] : CxObjPtr );
  304.   -102;
  305.  
  306. (*  TYPE SPECIFIC *)
  307.  
  308. LIBCALL (base : CommoditiesBasePtr) SetTranslate*
  309.   ( translator [8] : CxObjPtr;
  310.     VAR events [9] : IE.InputEvent );
  311.   -114;
  312. LIBCALL (base : CommoditiesBasePtr) SetFilter*
  313.   ( filter [8] : CxObjPtr;
  314.     text   [9] : ARRAY OF CHAR );
  315.   -120;
  316. LIBCALL (base : CommoditiesBasePtr) SetFilterIX*
  317.   ( filter [8] : CxObjPtr;
  318.     VAR ix [9] : IX );
  319.   -126;
  320. LIBCALL (base : CommoditiesBasePtr) ParseIX*
  321.   ( description [8] : ARRAY OF CHAR;
  322.     VAR ix      [9] : IX )
  323.   : LONGINT;
  324.   -132;
  325.  
  326. (*  COMMON MESSAGE *)
  327.  
  328. LIBCALL (base : CommoditiesBasePtr) CxMsgType*
  329.   ( cxm [8] : CxMsgPtr )
  330.   : SET;
  331.   -138;
  332. LIBCALL (base : CommoditiesBasePtr) CxMsgData*
  333.   ( cxm [8] : CxMsgPtr )
  334.   : E.APTR;
  335.   -144;
  336. LIBCALL (base : CommoditiesBasePtr) CxMsgID*
  337.   ( cxm [8] : CxMsgPtr )
  338.   : LONGINT;
  339.   -150;
  340.  
  341. (*  MESSAGE ROUTING *)
  342.  
  343. LIBCALL (base : CommoditiesBasePtr) DivertCxMsg*
  344.   ( cxm     [8] : CxMsgPtr;
  345.     headobj [9] : CxObjPtr;
  346.     ret    [10] : CxObjPtr );
  347.   -156;
  348. LIBCALL (base : CommoditiesBasePtr) RouteCxMsg*
  349.   ( cxm [8] : CxMsgPtr;
  350.     co  [9] : CxObjPtr );
  351.   -162;
  352. LIBCALL (base : CommoditiesBasePtr) DisposeCxMsg*
  353.   ( cxm [8] : CxMsgPtr );
  354.   -168;
  355.  
  356. (*  INPUT EVENT HANDLING *)
  357.  
  358. LIBCALL (base : CommoditiesBasePtr) InvertKeyMap*
  359.   ( ansicode [0] : E.ULONG;
  360.     event    [8] : IE.InputEventBasePtr;
  361.     km       [9] : KM.KeyMapPtr )
  362.   : BOOLEAN;
  363.   -174;
  364. LIBCALL (base : CommoditiesBasePtr) AddIEvents*
  365.   ( events [8] : IE.InputEventBasePtr );
  366.   -180;
  367.  
  368. (*--- functions in V38 or higher (Release 2.1) ---*)
  369.  
  370. (*  MORE INPUT EVENT HANDLING *)
  371.  
  372. LIBCALL (base : CommoditiesBasePtr) MatchIX  *
  373.   ( event [8] : IE.InputEventBasePtr;
  374.     ix    [9] : IXPtr )
  375.   : BOOLEAN;
  376.   -204;
  377.  
  378. (**-- C Macros defined as procedures -----------------------------------*)
  379. (** $L+ Absolute long addressing for globals *)
  380.  
  381. (*************************
  382.  * object creation macros
  383.  *************************)
  384.  
  385. (**-----------------------------------*)
  386. PROCEDURE CxFilter *
  387.   (base : CommoditiesBasePtr; d : E.STRPTR)
  388.   : CxObjPtr;
  389. BEGIN (* CxFilter *)
  390.   RETURN base.CreateCxObj (filter, d, NIL)
  391. END CxFilter;
  392.  
  393. (**-----------------------------------*)
  394. PROCEDURE CxTypeFilter *
  395.   (base : CommoditiesBasePtr; type : LONGINT)
  396.   : CxObjPtr;
  397. BEGIN (* CxTypeFilter *)
  398.   RETURN base.CreateCxObj (typeFilter, type, NIL)
  399. END CxTypeFilter;
  400.  
  401. (**-----------------------------------*)
  402. PROCEDURE CxSender *
  403.   (base : CommoditiesBasePtr; port : E.MsgPortPtr; id : LONGINT)
  404.   : CxObjPtr;
  405. BEGIN (* CxSender *)
  406.   RETURN base.CreateCxObj (send, port, id)
  407. END CxSender;
  408.  
  409. (**-----------------------------------*)
  410. PROCEDURE CxSignal *
  411.   (base : CommoditiesBasePtr; task : E.TaskPtr; sig : LONGINT)
  412.   : CxObjPtr;
  413. BEGIN (* CxSignal *)
  414.   RETURN base.CreateCxObj (signal, task, sig)
  415. END CxSignal;
  416.  
  417. (**-----------------------------------*)
  418. PROCEDURE CxTranslate *
  419.   (base : CommoditiesBasePtr; ie : IE.InputEventBasePtr)
  420.   : CxObjPtr;
  421. BEGIN (* CxTranslate *)
  422.   RETURN base.CreateCxObj (translate, ie, NIL)
  423. END CxTranslate;
  424.  
  425. (**-----------------------------------*)
  426. PROCEDURE CxDebug *
  427.   (base : CommoditiesBasePtr; id : LONGINT)
  428.   : CxObjPtr;
  429. BEGIN (* CxDebug *)
  430.   RETURN base.CreateCxObj (debug, id, NIL)
  431. END CxDebug;
  432.  
  433. (**-----------------------------------*)
  434. PROCEDURE CxCustom *
  435.   (base : CommoditiesBasePtr; action : CustomProcType; id : E.APTR)
  436.   : CxObjPtr;
  437. BEGIN (* CxCustom *)
  438.   RETURN base.CreateCxObj (custom, action, id)
  439. END CxCustom;
  440.  
  441.  
  442. (**-- Library Base variable --------------------------------------------*)
  443. (** $L- Address globals through A4 *)
  444.  
  445.  
  446. (**-----------------------------------*)
  447. PROCEDURE* CloseLib ();
  448.  
  449. BEGIN (* CloseLib *)
  450.   IF base # NIL THEN E.base.CloseLibrary (base) END;
  451. END CloseLib;
  452.  
  453. (**-----------------------------------*)
  454. PROCEDURE OpenLib * (mustOpen : BOOLEAN);
  455.  
  456. BEGIN (* OpenLib *)
  457.   IF base = NIL THEN
  458.     base :=
  459.       SYS.VAL
  460.         ( CommoditiesBasePtr,
  461.           E.base.OpenLibrary (name, E.libraryMinimum) );
  462.     IF base # NIL THEN SYS.SETCLEANUP (CloseLib)
  463.     ELSIF mustOpen THEN HALT (100)
  464.     END;
  465.   END;
  466. END OpenLib;
  467.  
  468.  
  469. BEGIN
  470.   base := NIL
  471. END Commodities.
  472.